package fan.string.Day05.io;

import java.io.*;
import java.util.Scanner;

/*
    *简易记事本
    * 程序启动后，要求将控制台输入的每一行字符串都按行写入到文件note.txt中
    * 当单独输入exit时程序退出
    * 要求，自行完成流连接
 */
public class PWDemo03 {
    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        FileOutputStream fos = new FileOutputStream("note.txt",true);
        OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw);

        System.out.println("请输入要记录的实践");
        Scanner scan = new Scanner(System.in);
        while (true) {

            String str = scan.nextLine();
            if (!("exit".equals(str))){
                pw.println(str);
                pw.flush();
                System.out.println("写入成功");

            }else {
                System.out.println("退出成功");
                break;
            }
            pw.close();

        }
    }
}
